<template>

	<view class="charts-box">
		<text>新增关注</text>
		<qiun-data-charts type="line" :opts="opts" :chartData="chartData1" errorMessage="自定义的错误信息，点击重新加载" />
		<text>取消关注</text>
		<qiun-data-charts type="line" :opts="opts" :chartData="chartData2" errorMessage="自定义的错误信息，点击重新加载" />
	
	<qiun-data-charts 
	      type="area"
	      :opts="opts"
	      :chartData="chartData3"
	      tooltipFormat="tooltipDemo1"
	    />
	
	</view>


</template>

<script>
	export default {
		data() {
			return {
				chartData1: {},
				chartData2: {},
				chartData3: {},
				//您可以通过修改 config-ucharts.js 文件中下标为 ['line'] 的节点来配置全局默认参数，如都是默认参数，此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式，达到页面简洁的需求。
				opts: {
					color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
						"#ea7ccc"
					],
					padding: [50],
					legend: {},
					xAxis: {
						disableGrid: true,
						labelCount: 4
					},
					yAxis: {
						gridType: "dash",
						dashLength: 2
					},
					extra: {
						line: {
							type: "straight",
							width: 2
						}
					}
				}
			};
		},
		onReady() {
			this.getServerData1();
			this.getServerData2();
			this.getServerData3();
		},
		methods: {
			getServerData1() {
				//模拟从服务器获取数据时的延时
				setTimeout(() => {
					//模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
					let res = {
						categories: ["2022-6-4", "2022-6-5", "2022-6-6", "2022-6-7", "2022-6-8",
							 "2022-6-9", "2022-6-10"
						],
						series: [{
							name: "新增关注",
							data: [56, 84, 94, 2, 77, 15, 12]
						}]
					};
					this.chartData1 = JSON.parse(JSON.stringify(res));
				}, 500);
			},
			getServerData2() {
				//模拟从服务器获取数据时的延时
				setTimeout(() => {
					//模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
					let res = {
						categories: ["2022-6-4", "2022-6-5", "2022-6-6", "2022-6-7", "2022-6-8",
							 "2022-6-9", "2022-6-10"
						],
						series: [{
							name: "取消关注",
							data: [10, 43, 56, 44, 33, 23, 12]
						}]
					};
					this.chartData2 = JSON.parse(JSON.stringify(res));
				}, 500);
			},
			getServerData3() {
			      //模拟从服务器获取数据时的延时
			      setTimeout(() => {
			        //模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
			        let res = {
			            categories: ["2022-6-4", "2022-6-5", "2022-6-6", "2022-6-7", "2022-6-8",
							 "2022-6-9", "2022-6-10"
						],
			            series: [
			              {
			                name: "新增关注",
			                data: [56, 84, 94, 2, 77, 15, 12]
			              },
			              {
			                name: "取消关注",
			                data: [10, 43, 56, 44, 33, 23, 12]
			              }
			            ]
			          };
			        this.chartData3 = JSON.parse(JSON.stringify(res));
			      }, 500);
			    },
		}
	};
</script>

<style scoped>
	/* 请根据实际需求修改父元素尺寸，组件自动识别宽高 */
	.charts-box {
		width: 100%;
		height: 300px;
	}
</style>
